'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'GPS print $GPRMC string
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
max = 20                                  ' maximum nbr of params
DIM arg$(max)                             ' used to hold the data fields
SETPIN 23, DOUT                               'GPS Power
PIN(23) = 0                                 'GPS Power ON
Settick 1000 ,B1,1                        'establish seconds "Tick Timer"



OPEN "COM2:9600" AS #1  ' open the GPS input 
'OPEN "COM1:9600" AS #2  ' open the radio link   NOT CONNECTED YET

DO                                        ' loop forever 
'PIN(23) = 0    
    GetGPSData                              ' get the next line 
   IF arg$(0) = "GPRMC" THEN               ' GPRMC contains lat/long 
   IF arg$(2) = "A" THEN                 ' "A" means locked on to satellites 
   GPSPRINT
   B3
   ELSE 
   PRINT "GPS searching..." 
   ENDIF 
   ENDIF 
LOOP


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' subroutine to load the GPS data fields into the array arg$()
' returns with the array populated
SUB GetGPSData
  DO
       DO WHILE INPUT$(1, #1) <> "$" : LOOP  ' wait for the start
    FOR i = 0 TO max
      arg$(i) = ""                        ' clear ready for data
      DO                                  ' loops until a specific exit
        x$ = INPUT$(1, #1)                ' get the character
        IF x$ = "," THEN EXIT             ' new data item, increment i
        IF x$ = "*" THEN EXIT SUB         ' we have all the data so exit
        arg$(i) = arg$(i) + x$            ' add to the data
      LOOP                                ' keep going
    NEXT i                                ' increment i
     LOOP
END SUB



   'B1 - 1 second Tick interrupt
Sub B1
   secs=secs+1                              'update seconds timer
   if secs => 43200 then                    '12 hrs reached
     secs = 0                               'reset counter
    Pin(23) = 0                             'GPS Power ON
   endif
end sub


sub B3
if secs = 240 then                            'after 4 minutes
PIN(23) = 1                                   'GPS Power OFF
end if
End sub

sub GPSPRINT
 PRINT "$"arg$(0)"," arg$(1)"," arg$(2)"," arg$(9)","            'Print Time and Date
end sub



































